home *** CD-ROM | disk | FTP | other *** search
- /*
- * Title:
- * control.c
- *
- * Authors:
- * Michael P. Schenck
- *
- * Purpose:
- * Control.c provides the management needed in opening and closing the
- * renderer. The opengraphics function takes the specifications for
- * the screen size, the colors used for the background and lines and
- * a path to the model library. This path is preappended to the model
- * path specified in the requestmodel function (see database.c)
- * A non-zero error value is returned if the renderer could not be opened.
- * The closegraphics function provides a method for shuting down
- * the renderer.
- *
- * Copyright Info:
- * Copyright (C) 1993, 1994 -- by Michael P. Schenck,
- * (mps4466@ultb.isc.rit.edu)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * For a copy of the GNU General Public License
- * write to the Free Software Foundation, 675 Mass Ave,
- * Cambridge, MA 02139, USA.
- *
- */
-
- #include <stdlib.h>
- #include "/include/types.h"
- #include "/include/errors.h"
- #include "/include/control.h"
- #include "/include/displaymap.h"
- #include "/include/transformation.h"
- #include "/include/viewperstrans.h"
- #include "/include/raster.h"
- #include "/include/database.h"
- #include "/include/display.h"
-
- static UBYTE error;
-
- UWORD width,height,x_center,y_center;
-
- /* Open the render environment. */
-
- UBYTE opengraphics(UWORD swidth,UWORD sheight,UWORD *coltable,UBYTE *modelpath)
-
- {
- /* Construct screen info. */
-
- width = swidth;
- height = sheight;
- x_center = swidth >> 1;
- y_center = sheight >> 1;
-
- /* Open the display screen. */
-
- if((error = opendisplay(coltable,swidth,sheight,1)) != SUCCESS)
- return(error);
-
- /* Open the model database. */
-
- opendatabase(modelpath);
-
- /* Open the perspective transformation system. */
-
- if((error = openviewperstrans())!=SUCCESS) {
- closedisplay();
- return(error);
- }
-
- /* Open the transformation system. */
-
- if((error = opentransformation())!=SUCCESS) {
- closeviewperstrans();
- closedisplay();
- return(error);
- }
-
- return(SUCCESS);
- }
-
- /* Run through the graphics pipeline. */
-
- void displaygraphics()
-
- {
- traversedisplaymap(); /* Update object verticies for objects that have changed. */
- transformvert(); /* Transform all of the verticies to the new view and clip. */
- scanconvert(); /* Draw the raster list of polys in the current view. */
- showgraphics(); /* Switch the double buffer screen. */
- clearscreen(); /* Clear the new screen. */
- }
-
- /* Close down the environment. */
-
- void closegraphics()
-
- {
- cleardisplaymap();
- closetransformation();
- closeviewperstrans();
- closedatabase();
- closedisplay();
- }
-